/*
 * Copyright 2009 Johnson Consulting Services
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 * http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */
/**
 * 
 */
package com.johnsoncs.gwt.widgets.samples.client;

import com.google.gwt.user.client.ui.Composite;
import com.google.gwt.user.client.ui.HorizontalPanel;
import com.google.gwt.user.client.ui.Hyperlink;
import com.google.gwt.user.client.ui.Label;
import com.johnsoncs.gwt.widgets.client.common.ListPanel;
import com.johnsoncs.gwt.widgets.client.common.ListPanel.ListType;

/**
 * @author wilj
 *
 */
public class ListPanelDemo extends Composite {
	public ListPanelDemo() {
		final HorizontalPanel panel = new HorizontalPanel();
		panel.add(createList(ListType.UNORDERED));
		panel.add(createList(ListType.ORDERED));
		panel.add(createStyledList());
		super.initWidget(panel);
	}

	private Hyperlink createLink(final String text) {
		final Hyperlink result = new Hyperlink(text, "");
		result.setStyleName("ExampleStyledList-Link");
		return result;
	}

	private ListPanel createList(final ListType type) {
		final ListPanel result = new ListPanel(type);
		result.add(new Label("A"));
		result.add(new Label("B"));
		result.add(new Label("C"));
		result.add(new Label("D"));
		return result;
	}

	private Label createSection(final String text) {
		final Label result = new Label(text);
		result.setStyleName("ExampleStyledList-Section");
		return result;
	}

	private ListPanel createStyledList() {
		final ListPanel result = new ListPanel(ListType.UNORDERED);
		result.setStyleName("ExampleStyledList");

		result.add(createSection("Section 1"));
		result.add(createLink("Item 1.1"));
		result.add(createLink("Item 1.2"));
		result.add(createLink("Item 1.3"));

		result.add(createSection("Section 2"));
		result.add(createLink("Item 2.1"));
		result.add(createLink("Item 2.2"));
		result.add(createLink("Item 2.3"));

		return result;
	}
}
